/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gm.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Med EL MOUDDENE
 */
@Entity
@Table(name = "atcd")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Atcd.findAll", query = "SELECT a FROM Atcd a"),
    @NamedQuery(name = "Atcd.findByIdAtcd", query = "SELECT a FROM Atcd a WHERE a.idAtcd = :idAtcd")})
public class Atcd implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_ATCD")
    private Integer idAtcd;
    @Lob
    @Size(max = 65535)
    @Column(name = "LIBELLE")
    private String libelle;
    @Lob
    @Size(max = 65535)
    @Column(name = "TYPE")
    private String type;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idAtcd")
    private Collection<TypeAtcd> typeAtcdCollection;
    @JoinColumn(name = "ID_DOSSIER", referencedColumnName = "ID_DOSSIER")
    @ManyToOne(optional = false)
    private DossierMedical idDossier;

    public Atcd() {
    }

    public Atcd(Integer idAtcd) {
        this.idAtcd = idAtcd;
    }

    public Integer getIdAtcd() {
        return idAtcd;
    }

    public void setIdAtcd(Integer idAtcd) {
        this.idAtcd = idAtcd;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @XmlTransient
    public Collection<TypeAtcd> getTypeAtcdCollection() {
        return typeAtcdCollection;
    }

    public void setTypeAtcdCollection(Collection<TypeAtcd> typeAtcdCollection) {
        this.typeAtcdCollection = typeAtcdCollection;
    }

    public DossierMedical getIdDossier() {
        return idDossier;
    }

    public void setIdDossier(DossierMedical idDossier) {
        this.idDossier = idDossier;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAtcd != null ? idAtcd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Atcd)) {
            return false;
        }
        Atcd other = (Atcd) object;
        if ((this.idAtcd == null && other.idAtcd != null) || (this.idAtcd != null && !this.idAtcd.equals(other.idAtcd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gm.entities.Atcd[ idAtcd=" + idAtcd + " ]";
    }
    
}
